clearvars -except Globaloption option

startdatenum = 1793;
enddatenum = 1860;
breakyear = 1860;

loaddata_4CIjoint_annual;
ttime = [startdate:enddate];
save(['MAT/res_annual_VAR_nodebt_US_pre', num2str(breakyear), '.mat'], '-regexp', '^(?!(option|Globaloption)$).');

option.bootstrap = 1;
output_rp = 0.03;

% Estimation
run ../../tools/cs_estimation.m
upper = exp(pxbar) * (mean(taxrevgdp - spendgdp));
gdpreturn = output_rp + y0nom_1 + yspr0 - pi0;

run ../../tools/BS_compute.m;
save MAT/benchmark_US_pre1860.mat k0x k1x s upper pdX pxbar gdpreturn s std_coeff gdebt output_rp pdT pdG CFT CFG DR taxrevgdp spendgdp

%%
clearvars -except Globaloption option

breakyear = 1860;
startdatenum = 1861;
enddatenum = 1946;
loaddata_4CIjoint_annual;
ttime = [startdate:enddate];
save(['MAT/res_annual_VAR_nodebt_US_post', num2str(breakyear), '.mat'], '-regexp', '^(?!(option|Globaloption)$).');

output_rp = 0.03;
run ../../tools/cs_estimation.m
upper = exp(pxbar) * (mean(taxrevgdp - spendgdp));
gdpreturn = output_rp + y0nom_1 + yspr0 - pi0;
run ../../tools/BS_compute.m;

save MAT/benchmark_US_post1860.mat k0x k1x s upper pdX pxbar gdpreturn s std_coeff gdebt output_rp pdT pdG CFT CFG DR taxrevgdp spendgdp



%% comparing the CS results with preWWII sample
clearvars -except Globaloption option 

breakyear = 1860;
load MAT/benchmark_US_pre1860.mat
s_pre1860 = s;
std_pre1860 = std_coeff;
gdebt_pre1860 = gdebt;
pdT_pre1860 = pdT;
pdG_pre1860 = pdG;
upper_pre1860 = upper;

load MAT/benchmark_US_post1860.mat
s_break = [s_pre1860'; s'];
std_break = [std_pre1860 std_coeff];
gdebt = [gdebt_pre1860; gdebt(2:end)];
upper = mean([upper * ones(68, 1); upper * ones(86, 1)]);
pdT_break = [pdT_pre1860'; pdT'];
pdG_break = [pdG_pre1860'; pdG'];

s_break_twoVAR = s_break;

f = figure;

ylimit = [1.5 1.5];
plot_CI(1793:1946, s_break', std_break, gdebt, upper, ylimit)

set(gcf, 'PaperUnits', 'inches', 'Units', 'inches');
f.PaperSize = [6 3.75];
print('../../results/figures_main/US/pre1946/cs_US_break_TwoVAR', '-dpdf', '-fillpage');
